package ita.class1.group2.supermarket.common.config;

import com.fasterxml.jackson.databind.annotation.JsonAppend;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Database configuration parameters
 *
 * @author Burgess Li
 * @date 2018/07/20
 */
public class DatabaseConfiguration {

    private String driverClass;
    private String url;
    private String username;
    private String password;

    public DatabaseConfiguration(InputStream inputStream) {
        Properties properties = new Properties();
        try {
            properties.load(inputStream);
            this.driverClass = properties.getProperty("driverClass");
            this.url = properties.getProperty("url");
            this.username = properties.getProperty("username");
            this.password = properties.getProperty("password");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public DatabaseConfiguration(String driverClass, String url, String username, String password) {
        this.driverClass = driverClass;
        this.url = url;
        this.username = username;
        this.password = password;
    }

    public String getDriverClass() {
        return driverClass;
    }

    public void setDriverClass(String driverClass) {
        this.driverClass = driverClass;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "DatabaseConfiguration{" +
                "driverClass='" + driverClass + '\'' +
                ", url='" + url + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }

}
